$string = rtrim($string_to_remove);
echo substr('a,b,c,d,e,', 0, -1); # => 'a,b,c,d,e'
$newarraynama = rtrim($arraynama, ", ");